package ejb.entities;

import java.io.Serializable;

import javax.persistence.*;

import ejb.dto.HotelDTO;

/**
 * The persistent class for the hotels database table.
 * 
 */
@Entity
@Table(name = "hotels")
@NamedQueries({
		@NamedQuery(name = "Hotel.findAll", query = "SELECT h FROM Hotel h"),
		@NamedQuery(name = "Hotel.findByDatesAndCity", query = "SELECT h FROM Hotel h WHERE h.basicproduct.startdate = :dataInizio AND h.basicproduct.enddate = :dataFine AND h.city LIKE :citta"),
		@NamedQuery(name = "Hotel.findByDates", query = "SELECT h FROM Flight h  WHERE h.basicproduct.startdate = :dataInizio AND h.basicproduct.enddate = :dataFine"), })
public class Hotel implements Serializable 
{
	private static final long serialVersionUID = 1L;

	public static final String FIND_ALL = "Hotel.findAll";
	public static final String FIND_DATES_CITY = "Hotel.findByDatesAndCity";
	public static final String FIND_DATES = "Hotel.findByDates";

	@Id
	@GeneratedValue(strategy = GenerationType.TABLE)
	private int hotelid;

	private String city;

	private String name;

	private int stars;

	// bi-directional one-to-one association to Basicproduct
	@OneToOne
	@PrimaryKeyJoinColumn(name = "hotelid") // readonly
	private Basicproduct basicproduct;

	public Hotel() {
	}

	public Hotel(HotelDTO hotelDTO) {
		this.city = hotelDTO.getCitta();
		this.name = hotelDTO.getNome();
		this.stars = hotelDTO.getStelle();
	}

	public int getHotelid() {
		return this.hotelid;
	}

	public void setHotelid(int hotelid) {
		this.hotelid = hotelid;
	}

	public String getCity() {
		return this.city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getStars() {
		return this.stars;
	}

	public void setStars(int stars) {
		this.stars = stars;
	}

	public Basicproduct getBasicproduct() {
		return this.basicproduct;
	}

	public void setBasicproduct(Basicproduct basicproduct) {
		this.basicproduct = basicproduct;
	}

}